const resolveApp = require('./paths');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
module.exports = {
  mode: "development",
  devServer: {
    hot: true,
    hotOnly: true,
    // publicPath: "/abc",
    watchContentBase: true,
    // host: "0.0.0.0",
    // port: 7777,
    // open: true,
    compress: true,
    // contentBase: path.resolve(__dirname, "./abc") // 第一种解决方案
    contentBase: resolveApp("./yz"), // 第二种解决方案
    proxy: {
      // "/api": "http://localhost:7777",
      "/yz": {
        target: "http://localhost:7777",
        pathRewrite: {
          "^/yz": ""
        },
        secure: false,
        changeOrigin: true
      },
    },
    // historyApiFallback: true,
    historyApiFallback: {
      rewrites: [
        {from: /abc/, to: "index.html" }
      ]
    }
  },
  plugins: [
    // 开发环境
    new ReactRefreshWebpackPlugin(),
  ]
}